!-----------------------------------------------------------------------
!  Copyright (c) 2020 Feasa Enterprises Ltd.
!  Rev 3.0  August 2020
!
!  All Rights Reserved.  Reproduction, adaptation, or translation
!  without prior written permission is prohibited, except as allowed
!  under the copyright laws.
!
!-----------------------------------------------------------------------
!
! Device        : Feasa_20i
! Manufacturer  : Feasa Enterprises Ltd.
! Description   : 20 Channel device to interrogate a LED
! Package       : 20 pin
! Test Platform : 3070
! Safeguard     : cmos_3v3
! Test          : Capture and Read Frequency - XYI
!-----------------------------------------------------------------------
! WARNING:  This is a Led Analyser function referenced by a PDL.
!
!   This test is not intended to be used directly for a Led analyser.
!   Instead, a part description library for the Led analyser should be
!   used where the part description language of that file refers to
!   this file as the part number of one of it's several "sub-components" .
!   Notice also that this test uses signal names rather than ordinal
!   pin numbers.  The referencing part description library should map
!   the device's actual pin numbers to these signal names.
!
!
! Additional Comments:
!
!   This test outputs the data of the LED under test.
!
!-----------------------------------------------------------------------

sequential
test time 3

vector cycle 112u
receive delay 111u

set terminators to on

assign Ser_out         to pins "Ser_out"
assign Ser_in          to pins "Ser_in"

assign Ser_clk         to pins "Ser_clk"

assign GND1               to pins "GND1"
assign Reset              to pins "Reset"

assign OE_bar             to pins "OE_bar"
assign Ext_trig           to pins "Ext_trig"

assign PWM                to pins "PWM"

assign Addr_0             to pins "Addr_0"
assign Addr_1             to pins "Addr_1"
assign Addr_2             to pins "Addr_2"
assign Addr_3             to pins "Addr_3"
assign Addr_4             to pins "Addr_4"

assign WE_bar             to pins "WE_bar"
assign Int                to pins "Int"
assign Color              to pins "Color"
assign Sat                to pins "Sat"

assign RyBy_bar           to pins "RyBy_bar"

assign VCC                to pins "VCC"
assign GND                to pins "GND"

power  VCC, GND, GND1

family   CMOS_3V3

inputs   OE_bar, Ext_trig, PWM, Addr_0, Addr_1, Addr_2, Addr_3,Addr_4, WE_bar, Reset

outputs  RyBy_bar

nondigital Int, Color, Sat, Ser_in, Ser_clk, Ser_out

!********************

vector Initialize
     set Reset  to "1"
     set WE_bar to "1"
     set OE_bar to "0"
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
     set Ext_trig to "1"
     set PWM    to "1"
end vector

vector Keep
     set Reset  to "1"
     set WE_bar to "k"
     set OE_bar to "k"
     set Addr_0 to "k"
     set Addr_1 to "k"
     set Addr_2 to "k"
     set Addr_3 to "k"
     set Addr_4 to "k"
     set Ext_trig to "1"
     set PWM    to "1"
end vector

vector Reset_lo
     initialize to Keep
     set Reset   to "0"
end vector

vector Reset_hi
     initialize to Keep
     set Reset   to "1"
end vector

vector RyBy_bar_lo
     initialize to Keep
     set RyBy_bar   to "0"
end vector

vector RyBy_bar_hi
     initialize to Keep
     set RyBy_bar   to "1"
end vector

vector WE_bar_lo
     initialize to Keep
     set WE_bar   to "0"
end vector

vector WE_bar_hi
     initialize to Keep
     set WE_bar   to "1"
end vector

vector OE_bar_lo
     initialize to Keep
     set OE_bar   to "0"
end vector

vector OE_bar_hi
     initialize to Keep
     set OE_bar   to "1"
end vector

vector Addr_00
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_01
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_02
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_03
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_04
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_05
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_06
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_07
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_08
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_09
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_10
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_11
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_12
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_13
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_14
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_15
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_16
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_17
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_18
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_19
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_20
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range1
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range2
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range3
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range4
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Capture_range5
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Pwm_low
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Pwm_high
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Set_factor_down
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Set_factor_reset
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Set_factor_up
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Addr_31
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector



!************  UNITS Section  ****************
!
! WE_bar going low triggers an event depending on the address
!
! **********  Unit Initialize  ****************
! This sequence has to be done in the correct order
! The Initialize unit has to be executed before any other command will work
! otherwise the Led Analyser will not capture
! Do not comment out this unit

unit "Initialize"
     execute Initialize

!   homingloop
!   execute    RyBy_bar_lo exit if pass  ! Debug check RyBy is low to start
!   end homingloop


     execute Addr_31    ! Reset the board in preparation for capture
     execute WE_bar_lo  ! execute the command

     homingloop
       execute    RyBy_bar_hi exit if pass !check that it goes high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass !check that it goes low
     end homingloop

     execute WE_bar_hi

end unit


!*************** Capture Units ******************
! The following list of units each execute a different capture command
! Un-comment one Capture unit and comment out all other capture units.
! Only one capture needs to be done.
! All LEDs have to be switched on before the capture unit is executed
! The colour and intensity of each LED is measured simultaneously and
! stored in RAM so that it can be later read back.
! The Colour and intensity is read back using the analog part of this
! mixed test.
! For debug purposes it is possible to connect to the Analyser using
! RS232 after the capture and read back the colour and intensity data
! to verify that the test has worked.
! It is recommended that an external RS232 connector is added to the
! test fixture for this purpose


!**************  This test is set in Auto range mode.  *********

unit "Auto Range Capture"
     execute Addr_00      ! Make a auto range capture
     execute WE_bar_lo    ! execute the command

     homingloop
       execute    RyBy_bar_hi exit if pass ! Check that RyBy_bar goes high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass ! Check that RyBy_bar goes low
     end homingloop

     execute WE_bar_hi

end unit

!************** Capture using the Low Range ****************
!unit "Capture Range #1"
!     execute Capture_range1  ! Make a range1 capture
!     execute WE_bar_lo       ! execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass ! Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass ! Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit

!*************** Capture using the medium range ***************
!unit "Capture Range #2"
!     execute Capture_range2  ! Make a range2 capture
!     execute WE_bar_lo       ! execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass ! Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass ! Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit

!*************** Capture using the high range ***************
!unit "Capture Range #3"
!     execute Capture_range3  ! Make a range3 capture
!     execute WE_bar_lo       ! execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass ! Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass ! Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit

!*************** Capture using the super range ***************
!unit "Capture Range #4"
!     execute Capture_range4  ! Make a range4 capture
!     execute WE_bar_lo       ! execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass ! Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass ! Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit

!*************** Capture using the ultra range ***************
!unit "Capture Range #5"
!     execute Capture_range5  ! Make a range5 capture
!     execute WE_bar_lo       ! execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass !Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass !Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit


!*************** Capture using the PWM_low range ***************
!unit "Capture PWM_Low"
!     execute Pwm_low                ! Make a PWM capture
!     execute WE_bar_lo              ! execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass ! Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass ! Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit

!*************** Capture using the PWM high range ***************
!unit "Capture PWM_High"
!     execute Pwm_high       ! Make a PWM capture
!     execute WE_bar_lo      ! execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass !Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass !Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit

! *******************************************************************************
! Measure the xy and Intensity for Fiber #1
! The address is set up for fiber #1 and the analog part of the test makes
! the frequency measurement

unit "Test xyi #1"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_01         ! Select Fiber 01

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #2
unit "Test xyi #2"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_02         ! Select Fiber 02

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #3
unit "Test xyi #3"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_03         ! Select Fiber 03

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #4
unit "Test xyi #4"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_04         ! Select Fiber 04

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #5
unit "Test xyi #5"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_05         ! Select Fiber 05

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #6
unit "Test xyi #6"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_06         ! Select Fiber 06

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #7
unit "Test xyi #7"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_07         ! Select Fiber 07

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #8
unit "Test xyi #8"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_08         ! Select Fiber 08

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   !Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #9
unit "Test xyi #9"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_09         ! Select Fiber 09

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #10
unit "Test xyi #10"
     execute WE_bar_hi
     execute OE_bar_lo       !Enable outputs
     execute Addr_10         !Select Fiber 10

     execute WE_bar_lo       !WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   !Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   !Wait for RyBy_bar to go low
     end homingloop

     continue analog            !measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #11
unit "Test xyi #11"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_11         ! Select Fiber 11

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #12
unit "Test xyi #12"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_12         ! Select Fiber 12

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #13
unit "Test xyi #13"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_13         ! Select Fiber 13

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #14
unit "Test xyi #14"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_14         ! Select Fiber 14

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #15
unit "Test xyi #15"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_15         ! Select Fiber 15

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #16
unit "Test xyi #16"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_16         ! Select Fiber 16

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #17
unit "Test xyi #17"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_17         ! Select Fiber 17

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #18
unit "Test xyi #18"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_18         ! Select Fiber 18

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #19
unit "Test xyi #19"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_19         ! Select Fiber 19

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int
end unit

! Measure the xy and intensity for Fiber #20
unit "Test xyi #20"
     execute WE_bar_hi
     execute OE_bar_lo       ! Enable outputs
     execute Addr_20         ! Select Fiber 20

     execute WE_bar_lo       ! WE_bar triggers the capture on a falling edge

     homingloop
       execute    RyBy_bar_hi exit if pass   ! Wait for RyBy_bar to go high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass   ! Wait for RyBy_bar to go low
     end homingloop

     continue analog            ! measure the xy and Int

end unit


!    End of Test
